package com.amex.uam.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.amex.uam.dao.ProjDao;
import com.amex.uam.model.Message;
import com.amex.uam.service.ProjService;
import com.amex.uam.util.Utils;

@Service("projService")
public class ProjServiceImpl implements ProjService {

	private ProjDao projDao;

	@Resource
	// byName default injection
	public void setProjDao(ProjDao projDao) {
		this.projDao = projDao;
	}

	@Override
	public Message loadAllProjects() {
		return new Message(Message.OK, projDao.loadAllProjects());
	}

	public Message getUserProjByMemberID(String amexWebId) {
		Message msg = null;
		if (Utils.isEmpty(amexWebId)) {
			msg = new Message(Message.ERROR_PARAM, "Invalid amexWebId: '" + amexWebId + "'");
		} else {
			msg = new Message(Message.OK, projDao.getUserProjByMemberID(amexWebId));	
		}
		return msg;
	}

	public Message getUserProjByUserID(String userId) {
		Message msg = null;
		if (Utils.isEmpty(userId)) {
			msg = new Message(Message.ERROR_PARAM, "Invalid userId: '" + userId + "'");
		} else {
			msg = new Message(Message.OK, projDao.getUserProjByUserID(userId));	
		}
		return msg;
	}
}
